home *** CD-ROM | disk | FTP | other *** search
-
- #include "parsehtm.h"
- #include <stdio.h>
-
- /* If we don't already have a case insensitive string compare
- * Make one
- */
- #ifndef strcasecmp
-
- int (strcasecmp)(const char *s1,const char *s2)
- {
- int returnValue = 1;
-
- if((NULL != s1)&&(NULL != s2))
- {
- char test1,test2;
-
- for(;;++s1,++s2)
- {
- test1 = tolower(*s1);
- test2 = tolower(*s2);
-
- if(test1 != test2)
- {
- returnValue =
- ((test1 < test2) ? -1:+1);
- break;
- }
- else if(test1 == '\0')
- {
- returnValue = 0;
- break;
- }
- }
- }
- else if((NULL == s1)&&(NULL == s2))
- {
- returnValue = 0;
- }
-
- return returnValue;
- }
-
- #endif
-
- void inputHandler(String ts,String as,String et,Dictionary td)
- {
- String type = 0;
-
- /* Get the tags type */
- type = dict_valueForKey(td,"TYPE");
-
- /* Update the tag string based on the type */
- if(type && type->string)
- {
- if(!strcasecmp(type->string,"text"))
- {
- string_appendString(ts," :: text field");
- }
- else if(!strcasecmp(type->string,"password"))
- {
- string_appendString(ts," :: password field");
- }
- else if(!strcasecmp(type->string,"checkbox"))
- {
- string_appendString(ts," :: checkbox");
- }
- else if(!strcasecmp(type->string,"radio"))
- {
- string_appendString(ts," :: radio");
- }
- else if(!strcasecmp(type->string,"submit"))
- {
- string_appendString(ts," :: submit");
- }
- else if(!strcasecmp(type->string,"hidden"))
- {
- string_appendString(ts," :: hidden field");
- }
- }
- }
-
- void main(int argc, char *argv[])
- {
- String output;
-
- /* Always call this first */
- initializeHtmlParsingLibrary();
-
- /* Register the handler */
- dict_setValueForKey(handlerDict,"INPUT", inputHandler);
-
- /* Parse the html file */
- output = parseHtml("inp_c.htm");
-
- /* Send the html to the client */
- if(output && output->string)
- {
- printf("Content-type: text/html\n\n");
- fwrite(output->string,sizeof(char),strlen(output->string),stdout);
- printf("\n");
-
- string_free(output);
- }
-
- exit(0);
- }
-
-